loading_view
code:script.js
let spinner = document.createElement("div");
spinner.style.position = "fixed";
spinner.style.bottom = "20px";
spinner.style.left = "20px";
spinner.style.padding = "4px";
spinner.style.borderRadius = "50%";
spinner.style.backgroundColor = "#ffffff";
spinner.style.fontSize = "0px";
spinner.style.zIndex = "1000";
let spinner_element = document.createElement("div");
spinner.appendChild(spinner_element);
spinner_element.id = "userscript-spinner";
let style_element = document.createElement("style");
spinner.appendChild(style_element);
style_element.innerText = `
width: 24px;
height: 24px;
border-bottom-color: transparent;
border-radius: 50%;
display: inline-block;
box-sizing: border-box;
animation: userscript-rotation .5s linear infinite;
}
@keyframes userscript-rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
*{cursor:wait !important;}
`;
function startbusy() {
document.body.appendChild(spinner);
}
function endbusy(e){
spinner.remove();
// updatelinks(e);
}
/*
function updatelinks(e) {
console.log(e)
v.removeEventListener("click", startbusy);
v.addEventListener("click", startbusy);
});
document.querySelectorAll('a.dropdown-toggle').forEach((v) => {
v.removeEventListener("click", startbusy);
});
if(scrapbox.Layout == "list") {
document.querySelector('.project-home').removeEventListener("click", startbusy);
}
document.querySelector('.stream-btn>a').removeEventListener("click", startbusy);
}
scrapbox.on("page:changed", endbusy);
scrapbox.on("layout:changed", endbusy);
scrapbox.on("lines:changed", updatelinks);
updatelinks();
window.addEventListener('popstate',startbusy);
*/
const target = document.querySelector('.status-bar');
let spinnerstat = false;
const observer = new MutationObserver(() => {
if(document.querySelector(".loading-status") == null){
if(spinnerstat == true){
spinner.remove();
spinnerstat = false;
}
}else{
if(spinnerstat == false){
document.body.appendChild(spinner);
spinnerstat = true;
}
}
});
observer.observe(target, {
childList: true
});